﻿@model TrialControllerModel.Index
<div style="width: 770px; margin: 0 auto">
    <div style="height: 358px; background: transparent url('http://image01.ouere.com/css/game/img/dxz/game.dxz.trail.jpg') no-repeat scroll 0 0;">
        <div>
            <div style="padding: 40px 10px 10px 15px;">
                <div class="row-fluid">
                    <div class="span4">
                        <div>
                            <div style="margin: 8px 30px;">
                                <img src="@Model.Server.Picture" class="img-polaroid" />
                            </div>
                        </div>
                        <div>
                            <div class="row-fluid">
                                <div class="span7">
                                    角色名：@(Model.User != null ? Model.User.RoleName : "--")
                                </div>
                                <div class="span5">
                                </div>
                            </div>
                            <div class="row-fluid">
                                <div class="span4">
                                    等级：@(Model.User != null ? Model.User.Level.ToString() : "--")
                                </div>
                                <div class="span2">
                                    <a href="">刷新</a></div>
                                <div class="offset2 span4">
                                    <a target="_blank" href="http://game.ouere.com/dxz/Index.aspx" style="">[进入官网]</a></div>
                            </div>
                            <div class="row-fluid">
                                <div class="span8">
                                    区服：@Model.Server.Name
                                </div>
                                <div class="span4">
                                    <a target="_blank" href="http://www.ouere.com/My/myv2.aspx?PageType=1">[个人中心]</a></div>
                            </div>
                            <div>
                                <div class="row-fluid">
                                    <div class="span7">
                                        游戏积分： <a href="http://www.ouere.com/service/faq.html#i01" target="_blank"><i class="icon-question-sign">
                                            &nbsp;</i></a>
                                    </div>
                                    <div class="span5">
                                        <div style="margin-left: 10px;">
                                            @if (!Request.IsAuthenticated)
                                            {
                                                <a target="_blank" href="" class="btn btn-inverse">开始试玩</a>
                                            }
                                            else
                                            {
                                                if (Model.User != null)
                                                {
                                                <a target="_blank" href="" class="btn btn-inverse" class="btn btn-inverse">继续试玩
                                                </a>
                                                }
                                                else
                                                {
                                                <a target="_blank" href="">开始游戏 </a>
                                                }
                                            }
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <p>
                            <a target="_blank" href="http://www.ouere.com/Auction/AuctionList.aspx">竞标赢得更多“游戏积分”>></a></p>
                        <p>
                            查看其他服务器：<a href="IFrame.aspx?gameId=3&serverId=23">双线十区 风起云涌</a></p>
                    </div>
                    <div class="span8">
                        <div style="position: relative;">
                            <p>
                                试玩周期：@Model.Server.StartTime.ToString("yyyy-MM-dd HH:mm") 至 @Model.Server.EndTime.ToString("yyyy-MM-dd HH:mm")</p>
                            <p style="color: red;">
                                注：请在试玩周期内自行领取等级奖励
                            </p>
                            <div style="position: absolute; right: 10px; top: 22px; width: 180px; color: white;
                                font-family: '微软雅黑'; font-size: 28px; font-weight: bold;">
                                <div class="row-fluid" style="text-align: center;">
                                    @{
                                        var now = DateTime.Now;
                                        var end = Model.Server.EndTime;
                                        var diff = end.Subtract(now);
                                    }
                                    <div class="span4">
                                        <span style="margin-right: 10px;">
                                            @(now > end ? 00 : diff.Days)
                                        </span>
                                    </div>
                                    <div class="span4">
                                        @(now > end ? 00 : diff.Hours)
                                    </div>
                                    <div class="span4">
                                        <span style="margin-left: 10px;">
                                            @(now > end ? 00 : diff.Minutes)
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>
                                            角色等级
                                        </th>
                                        <th>
                                            奖励积分
                                        </th>
                                        <th>
                                            状态
                                        </th>
                                        <th>
                                            角色等级
                                        </th>
                                        <th>
                                            奖励积分
                                        </th>
                                        <th>
                                            状态
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @for (var i = 0; i < 4; i++)
                                    {

                                        var a = Model.Trials.ToArray().Skip(i*2).FirstOrDefault();

                                        var b = Model.Trials.ToArray().Skip(i*2 + 1).FirstOrDefault();

                                        <tr>
                                            <td>@(a!=null&& a.Level > 0 ? a.Level.ToString() : "--")
                                            </td>
                                            <td>@(a != null && a.Integral > 0 ? a.Integral.ToString() : "--")
                                            </td>
                                            <td>
                                                @if (a != null && Model.User != null && !Model.Histories.Contains(a.Id) && Model.User.Level >= a.Level && (DateTime.Now >= Model.Server.StartTime && DateTime.Now <= Model.Server.EndTime))
                                                {
                                                    @:<a href="javascript:void(0);" onclick="getIntegral(@a.Id);">领取</a>
                                            }
                                                else if (a != null && Model.User != null && Model.User.Level < a.Level)
                                                {
                                                    @:未达成
                                            }
                                                else if (a != null && Model.User != null && Model.Histories.Contains(a.Id))
                                                {
                                                    @:已领取
                                            }
                                                else if (a != null && Model.User != null && (DateTime.Now > Model.Server.EndTime))
                                                {
                                                    @:已过期
                                            }
                                                else
                                                {
                                                    @:--
                                                                                                }
                                            </td>
                                           <td>@(b != null && b.Level > 0 ? b.Level.ToString() : "--")
                                            </td>
                                            <td>@(b != null && b.Integral > 0 ? b.Integral.ToString() : "--")
                                            </td>
                                            <td>
                                                @if (b != null && Model.User != null && !Model.Histories.Contains(b.Id) && Model.User.Level >= b.Level && (DateTime.Now >= Model.Server.StartTime && DateTime.Now <= Model.Server.EndTime))
                                                {
                                                    @:<a href="javascript:void(0);" onclick=" getPoint( @a.Id) ">领取</a>
                                            }
                                                else if (b != null && Model.User != null && Model.User.Level < b.Level)
                                                {
                                                    @:未达成
                                            }
                                                else if (b != null && Model.User != null && Model.Histories.Contains(b.Id))
                                                {
                                                    @:已领取
                                            }
                                                else if (b != null && Model.User != null && (DateTime.Now > Model.Server.EndTime))
                                                {
                                                    @:已过期
                                            }
                                                else
                                                {
                                                    @:--
                                                                                                }
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                        <p style="color: red; text-align: right; margin-right: 20px;">
                            @if (Model.User != null)
                            {
                                <a href="http://www.ouere.com/IntegralMall/Imall.aspx" target="_blank">查看可兑换的奖励>></a>
                            }
                            else
                            {
                                @: 温馨提示：您还未参与该游戏的试玩！参与试玩到达相应等级领取积分<a href="http://www.ouere.com/IntegralMall/Imall.aspx"target="_blank">兑换大礼</a>！
                                                        }
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div style="margin-top: 10px;">
    </div>
    <a href="http://www.ouere.com/News/AnnouncementList.aspx?aid=935" target="_blank">
        <img src="http://image01.ouere.com/css/game/img/game.point.2.jpg" alt="" /></a>
</div>

@section js{
    
    <script type="text/javascript">

        function getIntegral(id) {
            $.postJSON('/trial/integral', { param: id }, function (result) {
                if (result.Status == true) {
                    alert('领取成功！');
                    window.location.reload();
                }
                else {
                    if (result.Data == 0) {
                        result.Message = "不在时间范围内！";
                    }
                    if (result.Data == 1) {
                        result.Message = "该奖励你已领取过！";
                    }
                    alert(result.Message);
                }
            });
        }
    </script>
}